//
//  LJLRadioPageModel.m
//  聆听FM
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "LJLRadioPageModel.h"

@implementation LJLRadioPageModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    [super setValue:value forUndefinedKey:key];
    if ([key isEqualToString:@"radioPlayUrl"]) {
        self.playUrl = [value objectForKey:@"radio_64_aac"];
    }
    if ([key isEqualToString:@"picPath"]) {
        self.radioCoverLarge = value;
    }
    if ([key isEqualToString:@"id"]) {
        self.radioId = [value integerValue];
    }
}


- (void)encodeWithCoder:(NSCoder *)aCoder
{
    //序列化:(归档时使用)
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.programName forKey:@"programName"];
    [aCoder encodeObject:self.radioCoverLarge forKey:@"radioCoverLarge"];
    [aCoder encodeObject:self.playUrl forKey:@"playUrl"];
    [aCoder encodeObject:self.coverPath forKey:@"coverPath"];
    [aCoder encodeObject:self.rname forKey:@"rname"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.provinceName forKey:@"provinceName"];
    [aCoder encodeInteger:self.radioPlayCount forKey:@"radioPlayCount"];
    [aCoder encodeInteger:self.provinceCode forKey:@"provinceCode"];
    [aCoder encodeInteger:self.radioId forKey:@"radioId"];
    
}
//反序列化:(反归档时使用)
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self) {
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.programName = [aDecoder decodeObjectForKey:@"programName"];
        self.radioCoverLarge = [aDecoder decodeObjectForKey:@"radioCoverLarge"];
        self.playUrl = [aDecoder decodeObjectForKey:@"playUrl"];
        self.coverPath = [aDecoder decodeObjectForKey:@"coverPath"];
        self.rname = [aDecoder decodeObjectForKey:@"rname"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.provinceName = [aDecoder decodeObjectForKey:@"provinceName"];
        self.radioPlayCount = [aDecoder decodeIntegerForKey:@"radioPlayCount"];
        self.provinceCode = [aDecoder decodeIntegerForKey:@"provinceCode"];
        self.radioId = [aDecoder decodeIntegerForKey:@"radioId"];
    }
    return self;
}

@end
